package cn.pkubangbang.demo.democontact.entity;

/**
 * simple data structure for pagination
 * @Author: zhangzhenbang@k2data.com.cn
 * @Date: 2018-09-06 14:45
 */
public class PageInfo {

    private Long total;
    private Integer pageSize;
    private Integer page;

    public PageInfo(Integer pageSize, Integer page) {
        this.pageSize = pageSize;
        this.page = page;
    }

    public Long getTotal() {
        return total;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public Integer getPage() {
        return page;
    }

    public Long getStartIndexInclusive() {
        return ((long) page - 1) * pageSize;
    }

    public Long getEndIndexExclusive() {
        return (long) page * pageSize;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("PageInfo{");
        sb.append("total=").append(total);
        sb.append(", pageSize=").append(pageSize);
        sb.append(", page=").append(page);
        sb.append('}');
        return sb.toString();
    }

}
